export { dataurl2file, file2dataurl, sizeLimit, triggerFile } from 'dataurl-file'
export async function saveAs(url: string) {
  const blob = await getBlobFromUrl(url)
  const downloadUrl = window.URL.createObjectURL(blob)
  const a = document.createElement('a')
  a.setAttribute('download', 'download')
  a.href = downloadUrl
  document.body.append(a)
  a.click()
  a.remove()
  window.URL.revokeObjectURL(downloadUrl)
}
export function getBlobFromUrl(url: string) {
  return fetch(url).then(res => res.blob())
}